package com.patterns.iterator;

public class Test {
	public static void main(String[] args) {
		Children c = new Children();
		c.add(new Child("aaa"));
		c.add(new Child("bbb"));
		c.add(new Child("ccc"));
		c.add(new Child("ddd"));
		c.add(new Child("eee"));
		c.add(new Child("fff"));
		
		Iterator iterator = c.iterators();
		
		System.err.println(((Child)iterator.last()).getName());//fff
		System.err.println(iterator.isLast());//true
		
		System.err.println(((Child)iterator.first()).getName());//aaa
		System.err.println(iterator.isFirst());//true
		
		while (iterator.hasNext()) {
			System.out.println(((Child)iterator.next()).getName());//遍历
		}
		
	}
}
